﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

using CoDbObject;
using Colligate;

namespace Colligate.DataSource.DriverTraining
{
    public class DataSourceDriverTraining : BaseTaskDataSource
    {
        private DataNode_Root _RootDataBranch = null;

        public DataSourceDriverTraining()
            : base()
        {
            ClassGuid = "dc84ac5d-5a17-458c-b4a0-5988ed9cdbc0";
            IDataSourceLayer dataLayer = DataSourceLayerPool.GetDataSourceLayer(ConfigInfo.ConnectString, ConfigInfo.ConnectType);
            _RootDataBranch = new DataNode_Root(ClassGuid, dataLayer, DataService);
        }

        #region BaseTaskDataSource基本属性实现
        protected override string[] RoleList
        {
            get
            {
                return new string[] { "操作成员" };
            }
        }

        protected override string[] SetDataTypeList
        {
            get
            {
                string[] typeList = _RootDataBranch.DataTypeList(BaseDataTree.DataTypeCategory.SET_DATA_LIST);
                return typeList;
            }
        }

        protected override string[] GetDataTypeList
        {
            get
            {
                string[] typeList = _RootDataBranch.DataTypeList(BaseDataTree.DataTypeCategory.GET_DATA_LIST);
                return typeList;
            }
        }

        protected override string[] TransformDataTypeList
        {
            get
            {
                return _RootDataBranch.DataTypeList(BaseDataTree.DataTypeCategory.TRANSFORM_LIST);
            }
        }
        #endregion

        #region 重载父类函数
        public override int DeleteTaskData(OUDataInfo UserInfo, string DataGuid, string DataType)
        {
            if (_RootDataBranch.DataService == null)
                _RootDataBranch.DataService = this.DataService;
            return _RootDataBranch.DeleteData(UserInfo, DataGuid, DataType);
        }

        public override int SetTaskData(OUDataInfo UserInfo, string DataGuid, string DataType, System.Xml.XmlNode XmlData)
        {
            if (_RootDataBranch.DataService == null)
                _RootDataBranch.DataService = this.DataService;
            return _RootDataBranch.SetData(UserInfo, DataGuid, DataType, XmlData);
        }

        public override System.Xml.XmlNode GetTaskData(OUDataInfo UserInfo, string DataGuid, string DataType)
        {
            if (_RootDataBranch.DataService == null)
                _RootDataBranch.DataService = this.DataService;
            return _RootDataBranch.GetData(UserInfo, DataGuid, DataType); ;
        }

        public override System.Xml.XmlNode TransformTaskData(OUDataInfo UserInfo, System.Xml.XmlNode XmlParam)
        {
            if (_RootDataBranch.DataService == null)
                _RootDataBranch.DataService = this.DataService;
            string dataType = XmlParam.Attributes["DataType"].Value;
            return _RootDataBranch.TransformData(UserInfo, dataType, XmlParam);
        }

        public override void DoHasten()
        {
            if (_RootDataBranch.DataService == null)
                _RootDataBranch.DataService = this.DataService;
            return;
        }
        #endregion

    }
}
